package week2;

import java.util.Scanner;
public class getAge {
    public static void main(String[] args) {
        int[] age = new int[5];
        int a=age.length;
        GetAge(age, a);
        printAge(age, a);
        findMax(age, a);
        aveAge(age, a);}
        public static void GetAge( int[] age, int len)
            {
             Scanner scan = new Scanner(System.in);
             System.out.println("请输入5位同学的年龄");
                for (int i = 0; i < age.length; i++) {
                age[i] = scan.nextInt();
             }
            }

        private static void printAge(int[]age,int length)
        {
            System.out.println("5位同学的年龄如下：");
            for (int i = 0; i < age.length; i++) {
                System.out.println(age[i]);
            }
        }
        public static int findMax ( int[] age, int len)
        {
            int max = age[0];
            for (int i = 1; i < len; i++) {
                if (max < age[i]) {
                    max = age[i];
                }
                System.out.println(max);
            }
            return max;
        }
        public static double aveAge ( int[] age, int len) {
            int sum = 0;
            for (int i = 0; i < len; i++) {
                sum += age[i];
            }
            return (sum * 1.0 / len);
        }
    }





